using Code.GameLogic.XianJian.Controller;
using Code.GameLogic.XianJian.Element;
using Code.GameLogic.XianJian.XianJianBehavior.CommonBehavior;
using Unity.VisualScripting;
using UnityEngine;

namespace Code.GameLogic.XianJian.XianJianBehavior.MainBehavior
{
    public class Act1 : AbsActBehavior
    {
        private XianJianSpaceController _xianJianSpaceController;

        private XianJianFms _xianJianFms;

        private JianQiController _jianQiController;

        private XianJianController _xianJianController;

        public override bool CheckState()
        {
            return false;
        }

        public override void InState()
        {
            _xianJianFms = StateFsm;
            _xianJianController = StateFsm.xianJianController;
            _xianJianSpaceController = _xianJianController.xianJianSpaceController;
            //绑定剑气效果
            _jianQiController = _xianJianFms.AddComponent<JianQiController>();
            _jianQiController.InitController("Prefabs/JianQi/JianQi");
        }

        public override void OutState()
        {
            Debug.Log("OutState!");
        }

        public override void HoldState()
        {
            GameObject lockingObject = _xianJianSpaceController.lockingObject;
            if (lockingObject is not null)
            {
                LockTargetBehavior.LockAtTigerBox(this.StateFsm.gameObject, lockingObject, 5.1f);
                //执行攻击判定
                Attack(_jianQiController.ActiveBehaviour,_xianJianSpaceController.lockingObject, "ActionLocking");
            }
        }

        protected override double GetAsp()
        {
            return _xianJianController.bo.MainBehavior.Asp;
        }
    }
}